import java.io.*;

public class p1007 {
    static int[] N = new int[5001];
    public static void main(String[] args) throws IOException {
        PrintWriter p = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        StreamTokenizer sc = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        //独木桥的长度
        sc.nextToken();
        int L = (int)sc.nval;
        sc.nextToken();
        int n = (int)sc.nval;
        int max = 0;
        int min = 0;
        for(int i = 0; i < n; i++){
            sc.nextToken();
            int ret = (int)sc.nval;
            int mi = Math.min(ret, L + 1 - ret);
            min = Math.max(min, mi);
            int ma = Math.max(ret, L + 1 - ret);
            max = Math.max(max, ma);
        }
        System.out.println(min + " "+ max);
    }
}
